#ifndef MY_MORMAL_H
#define MY_NORMAL_H



#include "Main.h"



class Normal : public Main
{
public:
	Normal( CScene** ppScene, int nPassword )
	{
		m_ppScene			= ppScene;
		m_pLevelParam		= NULL;
		m_dwScore			= 0;
		m_dwHurryTick		= 0;
		m_dwLevelTimeTick	= 0;
		m_dwLevelTimeLeft	= 0;
		m_bLogicStart		= false;
		m_dwCurAboutString	= UN_DEFINE;

		CSquare::m_pMainScene = this;
		CMonster::m_pMainScene = this;

		SetupPassword( nPassword );

	}

	inline
	void SetupPassword( int nPassword )
	{
		switch( nPassword )
		{
		case NO_PW:
			{
				m_nCurHP		= DEFAULT_HEART_HP * DEFAULT_HEART;
				m_nMaxHeart		= DEFAULT_HEART;
				m_dwMoney		= g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatMoney : DEFAULT_MONEY;
				m_Hammer.InitHammer( g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatHammer : DEFAULT_HAMMER,
					g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatWings : DEFAULT_WINGS );
				m_dwLevel = g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatLevel : DEFAULT_START_LEVEL;

			} break;

		case PW_1:
			{
				g_CResource.PlaySound( SOUND_PW_OK );

				m_nMaxHeart		= DEFAULT_HEART;
				m_nCurHP		= DEFAULT_HEART_HP * m_nMaxHeart;
				m_dwMoney		= g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatMoney : 100;
				m_Hammer.InitHammer( g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatHammer : HAMMER_BRONZE,
					g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatWings : false );
				m_dwLevel = g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatLevel : DEFAULT_START_LEVEL;

			} break;

		case PW_2:
			{
				g_CResource.PlaySound( SOUND_PW_OK );

				m_nMaxHeart		= DEFAULT_HEART - 1;
				m_nCurHP		= DEFAULT_HEART_HP * m_nMaxHeart;
				m_dwMoney		= g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatMoney : 0;
				m_Hammer.InitHammer( g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatHammer : HAMMER_SILVER,
					g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatWings : true );
				m_dwLevel = g_CGame.GetSetting()->bCheatOn ? g_CGame.GetSetting()->dwCheatLevel : 10;

			} break;

		}

	}

	inline
	void InitScene()
	{
		Main::InitScene();

		m_pNextScene = new LevelInfo( m_ppScene, this, m_dwLevel );
		m_pNextScene->InitScene();
		m_pNextScene->SetAnimate( ANIME_FADE_OUT, ANIME_CMD_START_LOGIC );

	}

	inline
	virtual void RunGameWin()
	{
		if( m_dwCurAboutString != MAIN_CONGRATULATIONS )
		{
			g_CResource.StopMusic();
			g_CResource.PlaySound( SOUND_WIN );
			m_dwCurAboutString = MAIN_CONGRATULATIONS;

			if( !g_CGame.CheckPassword( 2 ) )
			{
				g_CGame.GetSetting()->dwPassword2 = g_CGame.CalPassword( 2 );
				g_CGame.SaveSetting();

			}

		}

		if( !ShowAboutString( m_dwCurAboutString ) )
		{
			InitAboutString( m_dwCurAboutString );

			if( !g_CGame.CheckPassword( 3 ) )
			{
				g_CGame.GetSetting()->dwPassword3 = g_CGame.CalPassword( 3 );
				g_CGame.SaveSetting();

			}

			*m_ppScene = new Menu( m_ppScene, true );
			((Menu*)*m_ppScene)->AddImgOption( MENU_BTN_BACK_TO_TITLE, MENU_BTN_TYPE_IMG_BTN );
			((Menu*)*m_ppScene)->AddImgOption( MENU_BTN_EXIT_GAME, MENU_BTN_TYPE_IMG_BTN );
			(*m_ppScene)->InitScene();
			return ;

		}

	}

	void SetLevel( DWORD dwLevel )
	{
		m_dwLevel = dwLevel;
		m_pLevelParam	= &g_LevelParam[dwLevel-1];

		for( int index = 0; index != 9; ++index )
			m_Square[index].m_fMoveSpeed = m_pLevelParam->fSquareSpeed;

		m_dwLevelTimeLeft = m_pLevelParam->dwLevelTime;

		if( m_pLevelParam->dwBoss )
		{
			m_Square[BOSS_SQUARE].SetupMonster( m_pLevelParam->dwBoss );
			m_Square[BOSS_SQUARE].SetToTop();

		}

		if( m_dwLevel == 10 && !g_CGame.CheckPassword( 2 ) )
		{
			g_CGame.GetSetting()->dwPassword2 = g_CGame.CalPassword( 2 );
			g_CGame.SaveSetting();

		}

	}

protected:

};



#endif